package cn.com.cifi.mars.service.transfer.impl;

import cn.com.cifi.mars.entity.PriceValueOrg;
import cn.com.cifi.mars.entity.PriceVersion;
import cn.com.cifi.mars.mapper.mars.TransferPriceValueOrgMapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.com.cifi.mars.entity.TransferPriceVersion;
import cn.com.cifi.mars.mapper.mars.TransferPriceVersionMapper;
import cn.com.cifi.mars.service.transfer.TransferPriceVersionService;

import java.util.List;

/**
 * <p>
 * 价格版本表 服务实现类
 * </p>
 *
 * @author yyd
 * @since 2019-11-27
 */
@Service
public class TransferPriceVersionServiceImpl extends ServiceImpl<TransferPriceVersionMapper, TransferPriceVersion> implements TransferPriceVersionService {

    @Autowired
    private TransferPriceVersionMapper transferPriceVersionMapper;

    @Autowired
    private TransferPriceValueOrgMapper transferPriceValueOrgMapper;

    @Override
    public void saveInfo(PriceVersion newVersion, List<PriceValueOrg> projectList, List<PriceValueOrg> groupInsertList, List<PriceValueOrg> productInsertList, List<PriceValueOrg> buildInsertList, List<PriceValueOrg> hoseSoleList, List<PriceValueOrg> parkSoleList) {
        //测试保存
        TransferPriceVersion transferPriceVersion = new TransferPriceVersion();
        BeanUtils.copyProperties(newVersion, transferPriceVersion);
        transferPriceVersionMapper.insert(transferPriceVersion);

        transferPriceValueOrgMapper.insertBatch(projectList);
        if (CollectionUtils.isNotEmpty(groupInsertList)) {
            transferPriceValueOrgMapper.insertBatch(groupInsertList);
        }
        if (CollectionUtils.isNotEmpty(productInsertList)) {
            transferPriceValueOrgMapper.insertBatch(productInsertList);
        }
        if (CollectionUtils.isNotEmpty(buildInsertList)) {
            transferPriceValueOrgMapper.insertBatch(buildInsertList);
        }
        if (CollectionUtils.isNotEmpty(hoseSoleList)) {
            transferPriceValueOrgMapper.insertBatch(hoseSoleList);
        }
        if (CollectionUtils.isNotEmpty(parkSoleList)) {
            transferPriceValueOrgMapper.insertBatch(parkSoleList);
        }
    }
}
